<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="commons/bar::header-fragment"></head>
	<body>
		<!--引入抽取的topbar-->
		<!--模板名：会使用thymeleaf的前后缀配置规则进行解析-->
		<div th:replace="commons/bar::topbar"></div>

		<div class="container-fluid">
			<div class="row">
				<!--引入侧边栏-->
				<div th:replace="commons/bar::#sidebar(activeUri='users')"></div>
				<main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
					<form th:action="@{/admin/user}" method="post">
						<!--发送put请求修改员工数据
							1、SpringMVC中配置HiddenHttpMethodFilter;（SpringBoot自动配置好的）
							2、页面创建一个post表单
							3、创建一个input项，name="_method";值就是我们指定的请求方式
						-->
						<input type="hidden" name="_method" value="put" th:if="${user!=null}"/>
						<input type="hidden" name="id" th:if="${user!=null}" th:value="${user.id}">
						<input type="hidden" name="password" th:if="${user!=null}" th:value="${user.password}">
						<div class="form-group">
							<label>名称</label>
							<input name="username" type="text" class="form-control" placeholder="antrain" th:value="${user!=null}?${user.username}">
						</div>

						<div class="form-group"  th:if="${user==null}">
							<label  th:if="${user==null}">密码</label>
							<input name="password" type="password" class="form-control" th:if="${user==null}" th:value="123456">
						</div>


						<div class="form-group">
							<label>Gender</label><br/>
							<div class="form-check form-check-inline">
								<input class="form-check-input" type="radio" name="sex" value="M" th:checked="${user!=null}?${user.sex=='M'}">
								<label class="form-check-label">男</label>
							</div>
							<div class="form-check form-check-inline">
								<input class="form-check-input" type="radio" name="sex" value="F" th:checked="${user!=null}?${user.sex=='F'}">
								<label class="form-check-label">女</label>
							</div>
						</div>

						<div class="form-group">
							<label>Birth</label>
							<input name="birth" type="date" class="form-control" th:value="${user!=null}?${#dates.format(user.birth, 'yyyy-MM-dd')}">
						</div>
						<button type="submit" class="btn btn-primary" th:text="${user!=null}?'修改':'添加'">添加</button>
					</form>
				</main>
			</div>
		</div>
		<div th:replace="commons/bar::footer-js"></div>
	</body>

</html>